package org.example.algorithm;

import org.apache.shardingsphere.infra.util.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import java.util.Collection;
import java.util.Collections;
import java.util.Properties;

@SingletonSPI
public class MyComplexAlgorithm implements ComplexKeysShardingAlgorithm<Comparable<?>> {

    public static ApplicationContext applicationContext;
    @Override
    public Collection<String> doSharding(Collection<String> collection, ComplexKeysShardingValue<Comparable<?>> complexKeysShardingValue) {
        MyComplexAlgorithmAware bean = applicationContext.getBean(MyComplexAlgorithmAware.class);
        Properties props = this.getProps();
        return collection;
    }

    @Override
    public Properties getProps() {
        return null;
    }

    @Override
    public void init(Properties properties) {

    }

    @Override
    public String getType(){
        return "MY_SHARDING";
    }

}
